home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
- #include <string.h>
- #include <ctype.h>
-
- #include "ifs.h"
- #include "rifs.h"
- #include "rclient.h"
- #include "local.h"
-
- void ShowUse(char *err)
- {
- if (err)
- printf("Error: %s\n", err);
- printf("Use:\n"
- " rport [local [TO server | REMOVE]]\n"
- "\n"
- "Examples:\n"
- " rport 1 to 1\n"
- " redirects output from LPT1 to server LPT1\n"
- " rport 1 remove\n"
- " removes redirection of LPT1\n"
- " rport\n"
- " show current redirections\n");
- exit(1);
- }
-
- int main(int argc, char **argv)
- {
- int RIFS=FindRIFS();
- struct REGPACK regs;
- BYTE *xlate;
- int local=0,
- remote=0;
-
- if (RIFS) {
- regs.r_ax=0x0000;
- intr(RIFS, ®s);
- }
- if (!RIFS || (regs.r_ax != 0x1234)) {
- fprintf(stderr, "RCLIENT not loaded");
- exit(1);
- }
- regs.r_ax=RCLIENT_GETPORTXLAT;
- intr(RIFS, ®s);
- xlate=MK_FP(regs.r_es, regs.r_bx);
-
- if (argc == 1) {
- int ii;
- printf("Current port mapping (locate --> server):\n");
- for (ii=0; ii < 3; ii++) {
- if (!xlate[ii])
- printf("\t%d --> local\n", ii+1);
- else
- printf("\t%d --> %d\n", ii+1, xlate[ii]);
- }
- } else {
- local=atoi(argv[1])-1;
- if ((local < 0) || (local > 2))
- ShowUse("local port must be 1, 2, or 3");
-
- if (stricmp(argv[2], "to") == 0) {
- if (argc != 4)
- ShowUse("no argument for TO");
- else {
- remote=atoi(argv[3]);
- if ((remote < 1) || (remote > 3))
- ShowUse("remote port must be 1, 2, or 3");
- }
- xlate[local]=remote;
- } else if (stricmp(argv[2], "remove") == 0) {
- if (argc != 3)
- ShowUse("too many parameters");
- else
- xlate[local]=0;
- } else
- ShowUse(NULL);
- }
-
- return 0;
- }